﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <!-- Title and other stuffs -->
    <title></title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="">
    <!-- Stylesheets -->
    <link href="../style/bootstrap.css" rel="stylesheet">
    <link rel="../stylesheet" href="style/font-awesome.css">
    <link href="../style/style.css" rel="stylesheet">
    <link href="../style/bootstrap-responsive.css" rel="stylesheet">

    <!-- HTML5 Support for IE -->
    <!--[if lt IE 9]>
    <script src="js/html5shim.js"></script>
    <![endif]-->
    <!-- Favicon -->
    <link rel="shortcut icon" href="img/favicon/favicon.png">
</head>

<body>
    @Html.AntiForgeryToken()
    <div class="admin-form">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <!-- Widget starts -->
                    <div class="widget wred">
                        <div class="widget-head">
                            <i class="icon-lock"></i> 注册
                        </div>
                        <div class="widget-content">
                            <div class="padd">

                                <form class="form-horizontal">
                                    <!-- Registration form starts -->
                                    <!-- Name -->
                                    <div class="form-group">
                                        <label class="control-label col-lg-3" for="name">用户名</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" id="name">
                                        </div>
                                    </div>           
                                    <!-- Password -->
                                    <div class="form-group">
                                        <label class="control-label col-lg-3" for="email">密码</label>
                                        <div class="col-lg-9">
                                            <input type="password" class="form-control" id="password">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-lg-3" for="email">密码确认</label>
                                        <div class="col-lg-9">
                                            <input type="password" class="form-control" id="Confirmpassword">
                                        </div>
                                    </div>
                                    <!-- Accept box and button s-->
                                    <div class="form-group">
                                        <div class="col-lg-9 col-lg-offset-3">
                                            <div class="checkbox">
                                                <label>
                                                    <input type="checkbox" id="IsCheck"> 注册条款
                                                </label>
                                            </div>
                                            <br />
                                            <button type="button" onclick="TRegister()" class="btn btn-danger">注册</button>
                                            <button type="reset" class="btn btn-success">重置</button>
                                        </div>
                                    </div>
                                    <br />
                                </form>

                            </div>
                        </div>
                        <div class="widget-foot">
                            已经注册? <a href="../Users/Login">登录</a>
                        </div>
                        <div id="AlertDiv" class="alert alert-warning hide">
                            两次密码输入不一直！
                        </div>
                        <div id="AlertModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                        <h4 class="modal-title">提示消息</h4>
                                    </div>
                                    <div class="modal-body">

                                        <p id="AlertContent">注册成功？</p>
                                    </div>

                                    <div class="modal-footer">
                                        <button type="button" onclick="callBack()" id="CancelButton" class="btn btn-default" data-dismiss="modal" aria-hidden="true">确认</button>
                                    </div>
                                </div>
                            </div>
                        </div>  
                    </div>
                </div>
            </div>
        </div>
    </div>



    <!-- JS -->
    <script src="../js/jquery.js"></script>
    <script src="../js/bootstrap.js"></script>
    <script src="../js/JqueryToken.js"></script>
    <script>
        function TRegister() {
            if ($("#IsCheck").is(':checked')) {
                if ($("#Confirmpassword").val() != $("#password").val() && $("#Confirmpassword").val() != "" && $("#password").val() != "") {
                    AlertMsg("两次密码输入不一直！");
                }
                else {
                    $.ajaxAntiForgery({
                        type: "post",
                        data: { UserName: $("#name").val(), Password: $("#password").val() },
                        url: "/Users/Register",
                        success: function (data) {

                            if (data.toString() == "OK") {
                                $("#AlertModal").modal("show");
                            }
                            else {
                                AlertMsg(data.toString().replace("error:", ""))
                            }
                        }
                    })
                }
            }
            else {
                AlertMsg("请阅读注册条款！");
            }
        }

        function callBack()
        {
            window.location.href="../Users/Login"
        }

        function AlertMsg( msg) {
            $("#AlertDiv").text(msg);
            $("#AlertDiv").attr("class", "alert alert-warning");
        }
    </script>
</body>
</html>